package cn.itcast.bos.quartz;

import java.util.Date;

import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.springframework.beans.factory.annotation.Autowired;

import cn.itcast.bos.service.take_delivery.PromotionService;
import cn.itcast.bos.service.take_delivery.WayBillService;


//使用quartz框架每隔一分钟就执行一次该job类中的方法
//如果传入的当前时间比失效时间大 就把promotion 宣传活动的statu状态修改为
public class PromotionJob implements Job{
 //属性注入service  因为service 层有事务管理   
	  @Autowired
	  private PromotionService promotionService;
	
	  @Autowired
	  private WayBillService wayBillService;
	
         @Override
        public void execute(JobExecutionContext context) throws JobExecutionException {
                  
        	System.out.println("活动过期处理程序执行！！！");
        	promotionService.updateStatus(new Date());
        }
         
         
         public void update(){
        	 System.out.println("执行一次");
        	 promotionService.updateStatus(new Date());
        	 System.out.println("同步索引库");
        	 wayBillService.syncIndex();
         }
}
